******************
* Western Europe *
******************
use "google_trend_we.dta", replace 
set scheme plotplain
encode country, generate(ctry)
tsset ctry date

* correlation
corr democracy far_right 
forvalues i=1/9{
	display `i'
	corr democracy far_right if ctry==`i'
}

graph twoway tsline coup democracy far_right if ctry==1, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 1' ({&rho}=0.209)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry1, replace)

graph twoway tsline coup democracy far_right if ctry==2, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 2' ({&rho}=0.296)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry2, replace)	

graph twoway tsline coup democracy far_right if ctry==3, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 3' ({&rho}=0.490)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry3, replace)	

graph twoway tsline coup democracy far_right if ctry==4, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 4' ({&rho}=0.587)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry4, replace)	
	
graph twoway tsline coup democracy far_right if ctry==5, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 5' ({&rho}=0.159)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry5, replace)	
	
graph twoway tsline coup democracy far_right if ctry==6, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 6' ({&rho}=0.248)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry6, replace)	
	
graph twoway tsline coup democracy far_right if ctry==7, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 7' ({&rho}=0.621)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry7, replace)
	
graph twoway tsline coup democracy far_right if ctry==8, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 8' ({&rho}=0.531)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry8, replace)
	
graph twoway tsline coup democracy far_right if ctry==9, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 9' ({&rho}=0.422)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry9, replace)
	
grc1leg ctry1.gph ctry2.gph ctry3.gph ctry4.gph ctry5.gph ctry6.gph ctry7.gph ctry8.gph ctry9.gph, title(" ")  graphregion(margin(zero))
graph export "gtrend_we.png", replace	


******************
* Eastern Europe *
******************
use "google_trend_ee.dta", replace 
set scheme plotplain
encode country, generate(ctry)
tsset ctry date

* correlation
corr democracy far_right 
forvalues i=1/11{
	display `i'
	corr democracy far_right if ctry==`i'
}

graph twoway tsline coup democracy far_right if ctry==1, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 1' ({&rho}=-0.046)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry1, replace)

graph twoway tsline coup democracy far_right if ctry==2, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 2' ({&rho}=0.459)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry2, replace)	

graph twoway tsline coup democracy far_right if ctry==3, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 3' ({&rho}=0.169)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry3, replace)	

graph twoway tsline coup democracy far_right if ctry==4, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 4' ({&rho}=0.261)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry4, replace)	
	
graph twoway tsline coup democracy far_right if ctry==5, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 5' ({&rho}=-0.229)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry5, replace)	
	
graph twoway tsline coup democracy far_right if ctry==6, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 6' ({&rho}=-0.029)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry6, replace)	
	
graph twoway tsline coup democracy far_right if ctry==7, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 7' ({&rho}=0.018)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry7, replace)
	
graph twoway tsline coup democracy far_right if ctry==8, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 8' ({&rho}= -0.059)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry8, replace)
	
graph twoway tsline democracy far_right if ctry==9, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 9' ({&rho}=-0.067)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry9, replace)

graph twoway tsline coup democracy far_right if ctry==10, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 10' ({&rho}=-0.051)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry10, replace)
	
graph twoway tsline coup democracy far_right if ctry==11, ///
	lcolor("255 87 51" "10 49 97" "156 78 151") lpattern("l" "l" "-") ylabel(0(20)100, nogrid labsize(2)) ///
	tline(06jan2021, lcolor(black) lpattern("l")) ///
	tlabel(25dec2020 6jan2021 25jan2021,  labsize(3) format(%tdDD-Mon-CCYY)) /// 
	ytitle(" ", size(2.0)) xtitle("Date", size(3.0)) ///
	title("`: label ctry 11' ({&rho}=-0.137)", size(4.0)) /// size needs some tuning
	legend(on pos(6) row(1) lab(1 "Coup") lab(2 "Democracy") lab(3 "Far-right politics") region(lstyle(l))) graphregion(margin(r+5)) scheme(plotplain) ///
	saving(ctry11, replace)	
	
grc1leg ctry1.gph ctry2.gph ctry3.gph ctry4.gph ctry5.gph ctry6.gph ctry7.gph ctry8.gph ctry9.gph ctry10.gph ctry11.gph, title(" ")  graphregion(margin(zero))
graph export "gtrend_ee.png", replace	